
#include "AbstractDialogx.hpp"

namespace NSCore {

	AbstractDialogx::AbstractDialogx(QWidget* p) :
		QDialog(p),
		AbstractObject()
	{
		setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
		m_layout = new QVBoxLayout;
		m_layout->setContentsMargins(2, 2, 2, 2);
		m_layout->setSpacing(0);

		m_confirm = new QPushButton(tr("ȷ��"), this);
		m_cancel = new QPushButton(tr("ȡ��"), this);
		connect(m_confirm, &QPushButton::clicked, this, &QDialog::accept);
		connect(m_cancel, &QPushButton::clicked, this, &QDialog::reject);
		QVBoxLayout* _layout = new QVBoxLayout;
		QHBoxLayout* button_layout = new QHBoxLayout;
		_layout->setContentsMargins(2, 2, 2, 2);
		_layout->setSpacing(2);
		button_layout->addWidget(m_cancel);
		button_layout->addWidget(m_confirm);
		_layout->addLayout(m_layout, 1);
		_layout->addLayout(button_layout);

		setLayout(_layout);
	}


	AbstractDialogx::~AbstractDialogx() {/*virtual*/ }


	void AbstractDialogx::setShowButton(bool show) {
		m_confirm->setVisible(show);
		m_cancel->setVisible(show);
	}

	void AbstractDialogx::addWidget(QWidget* _widget, int stretch) {
		m_layout->addWidget(_widget, stretch);

	}

}